import config
from document import Document
from dialog import getDialog
from utils import *

def register():
	return DialogTest()

class DialogTest:
	def __init__(self):
		self.type = 'passive'


	def run(self, gum, msg):
		if not msg['type'] in ['FriendMessage', 'GroupMessage'] \
				or len(msg['messageChain']) <= 1 \
				or not msg['sender']['id'] in config.utils.admins:
			return
		with getDialog(f'DialogTest{he()}') as diag:
			if msg['messageChain'][1]['type'] == 'Plain' \
					and msg['messageChain'][1]['text'].split()[0] == '*对话测试':
				diag.testing = True
			if msg['messageChain'][1]['type'] == 'Plain' \
					and msg['messageChain'][1]['text'].split()[0] == '*对话结束':
				diag.testing = False
			if diag.testing:
				diag.add(msg)
				auto(diag.msgs)